﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;

namespace ShutdownTimer
{
    public partial class ShutdownTimer : Form
    {
        public ShutdownTimer()
        {
            InitializeComponent();
        }

        String shutdown;
        private void button1_Click(object sender, EventArgs e)
        {
            Process.Start("shutdown", shutdown + " -t " + textBox1.Text + @" -c ""Windows is going to shutdown...""");
            timer1.Start();
            label3.Text = textBox1.Text;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Process.Start("shutdown", "-a");
            timer1.Stop();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
                case 0:shutdown = "-s";break;
                case 1:shutdown = "-r";break;
                case 2:shutdown = "-l";break;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label3.Text = (Convert.ToInt32(label3.Text) - 1).ToString();
        }
    }
}
